package com.soft.service;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

import com.soft.entity.Good;
import com.soft.entity.Good;
import com.soft.service.GoodService; // 补充 DeptService 的导入（根据注入逻辑推断）

@SpringBootTest
public class GoodServiceTest {

    @Autowired
    private GoodService goodService;

    //@Test
    public void queryAllTest() {
        List<Good> goodList = goodService.queryAll();
        Assert.notEmpty(goodList, "为空");
        Assert.isTrue(goodList.size()==5, "数据小于5条");
        for (int i = 0; i < goodList.size(); i++) {
            System.out.println(goodList.get(i).getGoodId());
        }
    }
    //@Test
    public void queryByNameTest()
    {
    	List<Good> goodList = goodService.queryByGoodName("雄安");
    	Assert.isTrue(goodList.size() == 3, "根据lco进行查询结果的数据不对");
    }
    @Test
    public void insertOneTest() {
        int num = goodService.insertOne("事业一部", "秦皇岛");
        Assert.isTrue(num == 1, "增加数据错误");
    }

    @Test
    public void deleteByIdTest() {
        int num = goodService.deleteById("1");
        Assert.isTrue(num == 1, "删除数据错误");
    }
    public void deleteByNameTest() {
        int num = goodService.deleteByName("gsw");
        Assert.isTrue(num == 1, "删除数据错误");
    }
    
  
}